package com.dubboconsumer.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import service.DemoService;

/**
 * @author: create by Young
 * @version: v1.0
 * @description: com.dubboconsumer.controller
 * @date:2019/4/2 8:57
 */
@RestController
public class DemoConsumerController {

	/**
	 * 生成远程服务代理，可以和本地bean一样使用demoService
	 * 相当于xml中 <dubbo:reference id="demoService" interface="org.apache.dubbo.demo.DemoService" />
	 *
	 */
	@Reference(version="${demo.service.version}")
	private DemoService demoService;

	@RequestMapping("/say/{name}")
	public String sayHello(@PathVariable("name") String name) {
		return demoService.sayHello(name);
	}
}
